<?php
defined('SYSPATH') or die('No direct script access.');

class Model_Place extends Kohana_Model{
     public function getAllPlace(){
         $sql = "SELECT * FROM patient_place";
         return Database::instance()->query(Database::SELECT, $sql, FALSE)->as_array();
     }

     public function add($data){
         return $query = DB::insert('patient_place',
                 array('pp_name','pp_url','pp_username','pp_password'
                      ,'pp_description'))
        ->values(array($data['pp_name'],$data['pp_url'],$data['pp_username']
                       ,$data['pp_password'],$data['pp_description']
                       ))->execute();
     }

     public function updateProfile($data){
         return DB::update('patient_place')
                ->set(array(
                    'pp_name'=>$data['pp_name'],
                    'pp_url'=>$data['pp_url'],
                    'pp_username'=>$data['pp_username'],
                    'pp_password'=>$data['pp_password'],
                    'pp_description'=>$data['pp_description']
                ))
                ->where('pp_id','=', $data['pp_id'])
                ->execute();
     }

     public function del($pp_id){
         return DB::delete("patient_place")
                    ->where('pp_id', '=',$pp_id)
                    ->execute();
     }

     public function getDataFromPP_id($pp_id){
         $sql = "SELECT * FROM patient_place WHERE pp_id=".$pp_id;
         return Database::instance()->query(Database::SELECT, $sql, FALSE)->as_array();
     }
}

?>
